safeDiv x y = if y == 0 then Nothing else Just (x/y)

safeHead :: [a] -> Maybe a
safeHead [] = Nothing
safeHead (x : xs) = Just x

inc x = x + 1



main = do putStrLn "input a number:"
          x <- readLn
          print(fmap (safeDiv 2) (safeDiv 1 x))
          print(safeDiv 1 x >>= safeDiv 2)
          print((safeHead [2, 4]) >>= safeDiv 2)
